package GUI.forms;

import java.awt.BorderLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JProgressBar;

import GUI.GUI;
import GUI.common.ExceptionI18N;
import engine.Analyzer;

public class FAnalyzerProgress extends GeneralForm implements PropertyChangeListener{
	private JProgressBar progressBar;
	private Analyzer analyzer;
	

	public FAnalyzerProgress(GUI gui, Analyzer analyzer) {
		super(gui);
		
		this.analyzer=analyzer;
		
		progressBar = new JProgressBar(0, 100);
        progressBar.setValue(0);
        progressBar.setStringPainted(true);
        
       
        JPanel panel = new JPanel();
        panel.add(progressBar);
        add(panel, BorderLayout.PAGE_START);        
        setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
                
    }
	
	public void start(){
		analyzer.addPropertyChangeListener(this);
        analyzer.execute();
	}


	@Override
	protected boolean validation() throws ExceptionI18N {
		// TODO Auto-generated method stub
		return false;
	}


	@Override
	public void propertyChange(PropertyChangeEvent evt) {
		 if ("progress" == evt.getPropertyName()) {
	            int progress = (Integer) evt.getNewValue();
	            progressBar.setValue(progress);	            
	        } 
		
	}
}
